package com.anti.modular.bus.roomdeposit.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.roomdeposit.param.RoomDepositParam;
import com.anti.modular.bus.roomdeposit.service.RoomDepositService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 房间押金表控制器
 *
 * @author anti
 * @date 2021-04-18 17:08:42
 */
@RestController
@RequestMapping("roomDeposit")
public class RoomDepositController {

    @Resource
    private RoomDepositService roomDepositService;

    /**
     * 查询房间押金表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @GetMapping("page")
    @BusinessLog(title = "房间押金表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, RoomDepositParam roomDepositParam) {
        return Result.data(roomDepositService.page(pageParam,roomDepositParam));
    }

    /**
     * 添加房间押金表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "房间押金表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(RoomDepositParam.add.class) RoomDepositParam roomDepositParam) {
            roomDepositService.add(roomDepositParam);
        return Result.success("新增成功");
    }

    /**
     * 删除房间押金表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "房间押金表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(RoomDepositParam.delete.class) RoomDepositParam roomDepositParam) {
            roomDepositService.delete(roomDepositParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑房间押金表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "房间押金表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(RoomDepositParam.edit.class) RoomDepositParam roomDepositParam) {
            roomDepositService.edit(roomDepositParam);
        return Result.success("修改成功");
    }

    /**
     * 查看房间押金表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @GetMapping("detail")
    @BusinessLog(title = "房间押金表_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result detail(@Validated(RoomDepositParam.detail.class) RoomDepositParam roomDepositParam) {
        return Result.data(roomDepositService.detail(roomDepositParam));
    }

    /**
     * 房间押金表列表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @GetMapping("list")
    @BusinessLog(title = "房间押金表_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result list(RoomDepositParam roomDepositParam) {
        return Result.data(roomDepositService.list(roomDepositParam));
    }
    /**
     * 房间押金表列表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @GetMapping("getDepositListByRoomId/{roomId}")
    public Result getDepositListByRoomId(@PathVariable(name = "roomId") Long roomId) {
        return Result.data(roomDepositService.getDepositListByRoomId(roomId));
    }
    /**
     * 房间押金表列表
     *
     * @author anti
     * @date 2021-04-18 17:08:42
     */
    @GetMapping("getDepositListByLeaseId/{leaseId}")
    public Result getDepositListByLeaseId(@PathVariable(name = "leaseId") Long leaseId) {
        return Result.data(roomDepositService.getLeaseDepositListByLeaseId(leaseId));
    }

}
